<template>
  <div class="child">
    <h2>我是子组件，{{ car.name }}--{{ car.price }}</h2>
    <Son></Son>
  </div>
</template>

<script>
import { inject } from "vue";
import Son from "./son";

export default {
  name: 'ChildTest',
  components: { Son },
  setup() {

    // inject 使用祖 组件传来的数据
    let car = inject('car')

    return { car }
  }
}
</script>

<style>
.child {
  background-color: skyblue;
  padding: 10px;
}
</style>